//
//  ResultTextCell.m
//  iiecg
//
//  Created by Shanlin on 2017/3/1.
//  Copyright © 2017年 Boundary Technology. All rights reserved.
//

#import "ResultTextCell.h"

@interface ResultTextCell()
@property (weak, nonatomic) IBOutlet UILabel *textLabel;

@property(nonatomic,strong)ResultTextBean *bean;

@end

@implementation ResultTextCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.textLabel.font = [UIFont systemFontOfSize:15];
}

-(void)setBean:(ResultTextBean *)bean
{
    __weak typeof(self)weakSelf = self;
    _bean = bean;
    if (!bean) {
        return;
    }
    [IKPublicUtil runOnMainThread:^{
        weakSelf.textLabel.text = bean.text;
        weakSelf.textLabel.textColor = bean.textColor;
    }];
}

+(instancetype)createWith:(UITableView *)tableView bean:(ResultTextBean *)bean
{
    static NSString *ID = @"ResultTextCell";
    ResultTextCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:ID owner:nil options:nil] lastObject];
    } else {
        while ([cell.contentView.subviews lastObject] != nil) {
            [(UIView *)[cell.contentView.subviews lastObject] removeFromSuperview];
        }
    }
    cell.bean = bean;
    return cell;

}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
